home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / OpenDoc / Interfaces / Handmade / QDFixM.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-13  |  1.7 KB  |  56 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        QDFixM.h
  3.  
  4.     Contains:    Fix for QuickDraw.h   [Mac Only]
  5.  
  6.     Written by:    Jens Alfke
  7.  
  8.     Copyright:    © 1993-94 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <1>     1/25/95    jpa        first checked in
  13.                                  ---Moved to ODSOM:Interfaces:Handmade:
  14.          <3>     9/14/94    jpa        Commented out #error so people can use
  15.                                     standard precompiled headers. Of course, if
  16.                                     QuickDraw.h is included before me, the fix
  17.                                     will NOT take effect...
  18.          <2>     8/18/94    TÇ        #1181622 Removed my name from the Written
  19.                                     By: field
  20.          <1>     7/19/94    jpa        first checked in
  21.     To Do:
  22.     
  23.     Theory of Operation:
  24.  
  25.     We've had a lot of trouble with QuickDraw.h defining an enum constant
  26.     called "frame" whose value is zero. If a function uses a local variable
  27.     "frame" but forgets to define it, the global frame is used instead. Since
  28.     it's zero, which can be cast implicitly to NULL, this usually results in a
  29.     null pointer being used instead of an XMPFrame, leading to obscure crashes
  30.     later on. We have spent literally days tracking down problems stemming
  31.     from this.
  32.     To fix this, we employ some sleight-of-hand to prevent QuickDraw.h from
  33.     defining that constant by renaming it "kQDFrameVerb". This way the
  34.     compiler will properly generate a syntax error if some schmuck forgets
  35.     to declare a local "frame" variable.
  36.     
  37.     This header should be included before <QuickDraw.h>.
  38.     This header is included by ODTypesF.h.
  39.  
  40.     In Progress:
  41. */
  42.  
  43.  
  44. #ifndef _QDFIXM_
  45. #define _QDFIXM_
  46.  
  47. #ifdef __QUICKDRAW__
  48. /*    #error "Yo! Please include QDFix.h _before_ QuickDraw.h!" */
  49. #else
  50.     #undef frame
  51.     #define frame kQDFrameVerb        // Use this instead of "frame" in QD grafProcs.
  52.     #include <QuickDraw.h>
  53.     #undef frame
  54. #endif
  55.  
  56. #endif /*_QDFIXM_*/